<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>打印</title>
<style>
body {
	font-family: "宋体","微软雅黑"; font-size: 12px; color: #404040; line-height: 1.2em;
	background-color: #FFF;
}
@media print {
.noprint { display: none;color:green }
}
.f_clear:after {
	content: "."; display: block; height: 0; clear: both; visibility: hidden;
}

.f_clear {
	display: inline-table;
}

* html .f_clear {
	height: 1%;
}

*+html .f_clear {
	height: 1%;
}

.f_clear {
	display: block;
}

.clear {
	clear: both;
}

form {
	margin: 0px; padding: 0px;
}

#main {
	margin: auto; width: 165px;
}

.order {
	padding: 10px 0px; 
}

.order .store {
	font-weight: bold; line-height: 3em; font-size: 14px;
}

ul.info {
	list-style-type: none; margin: 0px; padding: 0px 0px 8px 0px; height: auto; display: block;
}

ul.info li {
	padding: 2px 0px;
}

.order table {
	border-collapse:collapse;
}

.order table th {
	border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #999;
}

.order table tr {
	border-bottom-width: 1px; border-bottom-style: dashed; border-bottom-color: #999;
}

.order table td,.order table th {
	text-align: left; vertical-align: top; padding: 0px 8px 0px 0px; font-weight: normal;
}

ul.total {
	display: block; margin: 0px; padding: 0px; list-style-type: none; height: auto;
}

ul.total li {
	float: left; padding-right: 20px; display: block;
}
</style>
</head>
<body>
	<div id="main">
		
	</div>
	<div id="orderItemTmp" style="display:none;">
	 	<div class="order" >
			<div class="store">-{storeName}-</div>
			<ul class="info">
				<li>单号：-{orderCode}-</li>
				<li>时间：-{orderTime}-</li>
				<li>收货人：-{consignee}- -{phone}-</li>
				<li>地址：-{address}-</li>
			</ul>
		</div>
		<div style="text-align:right;margin-bottom:20px;">
		          合计：￥ -{realCost}-<br>
		</div>
		<div style="text-align:center;margin-bottom:20px;">
			欢迎下次光临！-{storePhone}-<br>
		</div>
		<div style="margin-top:20px;">.</div>
	</div>
	<div id="pickTmp" style="display:none;">
	 	<div class="order" >
			<div class="store">捡物小票</div>
		</div>
		<div style="margin-top:20px;">.</div>
	</div>
	<script src="${st.resDomain}/scripts/jquery-1.9.1.min.js"></script>
	<script>
	var orderItemTmp = $("#orderItemTmp").html();
	var pickTmp = $("#pickTmp").html();
	
	// 打印订单
 	 function printOrder() {
		 $("#main").empty();
		 var $checkboxs = $(window.parent.document).find(":checkbox[name='orderIds']:checked");
		 $checkboxs.each(function() {
			 var orderId = $(this).val();
			 var itemTmp = orderItemTmp;
			 var table = "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><th colspan='3'>商品名称</th></tr><tr><th>单价</th><th>数量</th><th>小计(￥)</th></tr>"
			 var $orderGoodsDiv = $(window.parent.document).find("[id^='ogParams_" + orderId + "']");
			 $orderGoodsDiv.each(function () {
				var ogStr = $(this).html();
				var og = $.parseJSON(ogStr);
				table += "<tr><td colspan='3'>" + og.name + "</td></tr><tr><td>" + og.price + "</td><td>" + og.realCount + "</td><td>" + og.realCost + "</td></tr>";
			});
			var orderStr = $(window.parent.document).find("#orderParams_" + orderId).html();
			var order = $.parseJSON(orderStr);
			table = table + "</table>";
			itemTmp = itemTmp
			.replace(/\-\{storeName\}\-/g, order.storeName)
			.replace(/\-\{orderCode\}\-/g, order.orderCode)
			.replace(/\-\{orderTime\}\-/g, order.orderTime)
			.replace(/\-\{consignee\}\-/g, order.consignee)
			.replace(/\-\{phone\}\-/g, order.phone)
			.replace(/\-\{address\}\-/g, order.address)
			.replace(/\-\{realCost\}\-/g, order.realCost)
			.replace(/\-\{storePhone\}\-/g, order.storePhone);
			var $orderTip = $('<div>').append(itemTmp);
	 		$orderTip.find(".info").after(table);
	 		$("#main").append($orderTip.children());
		 });
	 } 
	 
	// 打印捡物小票
	function printPick() {
		$("#main").empty();
		var table = "<table width='100%' border='0' cellspacing='0' cellpadding='0' ><tr><th width='110px;'>商品名称</th><th>数量</th></tr>";
		var $checkboxs = $(window.parent.document).find(":checkbox[name='orderIds']:checked");
		$checkboxs.each(function() {
			var orderId = $(this).val();
			var $orderGoodsDiv = $(window.parent.document).find("[id^='ogParams_" + orderId + "']");
			$orderGoodsDiv.each(function () {
				var ogStr = $(this).html();
				var og = $.parseJSON(ogStr);
				var buyUnit = og.buyUnit === "" ? og.unit : og.buyUnit;
				table += "<tr><td width='110px;'>" + og.name + "</td><td>" + og.buyCount + buyUnit + "</td></tr>";
			});
		});
		table = table + "</table>";
		var $pickTip = $('<div>').append(pickTmp);
		$pickTip.find(".store").after(table);
		$("#main").append($pickTip.children());
	}
	</script>
</body>
</html>
